﻿using Autodesk.Windows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZhuXingFamilys.utils
{
    /// <summary>
    /// 禁用和启用按钮工具
    /// </summary>
    public class PanelEnableDisableUtils
    {
        public static void CheckAuthority(int authority)
        {
            if (authority == 0)
            {
                PanelEnable("筑星族库");
                PanelEnable("雁伴毕姆");
            }
            if (authority == 1)
            {
                PanelEnable("筑星族库");
                PanelDisable("雁伴毕姆");
            }
            if (authority == 2)
            {
                PanelDisable("筑星族库");
                PanelEnable("雁伴毕姆");
            }
        }
        public static void PanelEnable(string tabName)
        {
            foreach (Autodesk.Windows.RibbonTab tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
            {
                if (tab.Id == tabName)
                {
                    foreach (var Panel in tab.Panels)
                    {
                        Panel.IsEnabled = true;
                    }
                }
            }
        }

        public static void PanelEnable(string tabName, string panelName)
        {
            foreach (Autodesk.Windows.RibbonTab tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
            {
                if (tab.Id == tabName)
                {
                    foreach (var Panel in tab.Panels)
                    {
                        if (Panel.Source.Name == panelName)
                        {
                            Panel.IsEnabled = true;
                        }
                    }
                }
            }
        }

        public static void PanelDisable(string tabName)
        {
            foreach (Autodesk.Windows.RibbonTab tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
            {
                if (tab.Id == tabName)
                {
                    foreach (var Panel in tab.Panels)
                    {
                        if (Panel.Source.Name != "帮助")
                            Panel.IsEnabled = false;
                    }
                }
            }
        }

        public static void PanelDisable(string tabName, string panelName)
        {
            foreach (Autodesk.Windows.RibbonTab tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
            {
                if (tab.Id == tabName)
                {
                    foreach (var Panel in tab.Panels)
                    {
                        if (Panel.Source.Name == panelName)
                        {
                            Panel.IsEnabled = false;
                        }
                    }
                }
            }
        }
    }
}
